//
//  ProjectInfoCell.swift
//  QualityControlSystem
//
//  Created by Daniel Hu on 1/5/17.
//  Copyright © 2017 com.mask. All rights reserved.
//

import UIKit
import SnapKit

class ProjectInfoCell: UITableViewCell {
    
    //MARK: - Properties
    
    let number = UILabel()
    let projectName = UILabel()
    let progress = UILabel()
    let location = UILabel()
    var data: ProjectInfo? {
        willSet {
            number.text = newValue?.numbers
            projectName.text = newValue?.names
            location.text = newValue?.address
            progress.text = newValue?.progress
        }
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        setupSubviews()
    }
    
    func setupSubviews() {
        // number
        addSubview(number)
        number.snp.makeConstraints({ make in
            make.top.equalTo(self).offset(Padding.top)
            make.left.equalTo(self).offset(Padding.left)
            make.width.equalTo(100)
            make.height.equalTo(25)
        })
        
        // project name
        addSubview(projectName)
        projectName.snp.makeConstraints({ make in
            make.top.equalTo(number)
            make.left.equalTo(number.snp.right).offset(5)
            make.width.equalTo(Screen.width)
            make.height.equalTo(30)
        })
        
        // location
        location.textColor = Color.textGray
        location.font = UIFont.systemFont(ofSize: 12)
        addSubview(location)
        location.snp.makeConstraints({ make in
            make.bottom.equalTo(self).offset(-5)
            make.left.equalTo(number)
            make.width.equalTo(Screen.width)
            make.height.equalTo(25)
        })
        
        // progress
        progress.textAlignment = .right
        progress.textColor = Color.textGray
        progress.font = UIFont.systemFont(ofSize: 12)
        addSubview(progress)
        progress.snp.makeConstraints({make in
            make.right.equalTo(self).offset(-30)
            make.centerY.equalTo(self)
            make.width.equalTo(Screen.width)
            make.height.equalTo(30)
        })
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
